This commit is contained in:
julianb0 2019-05-30 19:07:04 +02:00
parent fd5dc45ff3
commit 58ca78f1f1
No known key found for this signature in database
GPG Key ID: DDF8325C95299A62
3 changed files with 19 additions and 5 deletions

View File

@ -9,21 +9,20 @@ main:
mov ax0, .msg
call print
break
mov ax0, .buf
mov ax1, .msg
call strrev
break
prn 10
mov ax0, .buf
call print
leave
ret
.msg = "Hello World :)\n"
.buf = " "
.msg = "Hello World :)"
.buf = "!!!!!!!!!!!!!!!!"
;
; Exit function

View File

@ -10,8 +10,11 @@ strrev:
jz .4
; save str's location
mov rdx, ax1
; xxx why is dec'ing needed?
lea rdx, b[ax1 + -1]
; go to str's end, just before
; the null terminator
.1:
test b[ax1+1], b[ax1+1]
jz .2
@ -19,6 +22,8 @@ strrev:
inc ax1
jmp .1
; copy, going backward though str
; and forward through buf
.2:
mov b[ax0], b[ax1]

View File

@ -94,6 +94,15 @@ void writemem8(ctx_t *ctx, ulong val, ulong addr)
ushort v = ctx->mp[real];
if (!(addr % 2)) {
ctx->mp[real] = ((v & 0xFF00) << 8) | (val & 0xFF);
}
else {
ctx->mp[real] = (v & 0xFF) | (((val & 0xFF) << 8));
}
/*
if (addr % 2) {
ctx->mp[real] = (v & 0xFF00) | (val & 0xFF);
}
@ -101,6 +110,7 @@ void writemem8(ctx_t *ctx, ulong val, ulong addr)
else {
ctx->mp[real] = (v & 0xFF) | (((val & 0xFF) << 8));
}
*/
}
void writemem16(ctx_t *ctx, ulong val, ulong addr)