cmp16 pseudoop

This commit is contained in:
Joshua Bell 2018-02-06 10:06:44 -08:00
parent d09aa8705d
commit 956c41c069
2 changed files with 164 additions and 326 deletions

View File

@ -1443,10 +1443,7 @@ L9AAF: lda L9C7A,x
sta L9C75
lda L9C77
bmi L9AF7
lda L9C7A
cmp #$30
lda L9C7B
sbc #$02
cmp16 L9C7A, #$230
bcs L9AFE
jsr L9DFA
jmp L9B0E
@ -1462,15 +1459,9 @@ L9B03: jsr L9DB8
sta L9C75
L9B0E: lda L9C79
bmi L9B31
lda L9C78
cmp #$0D
lda L9C79
sbc #$00
cmp16 L9C78, #$0D
bcc L9B31
lda L9C7C
cmp #$C0
lda L9C7D
sbc #$00
cmp16 L9C7C, #$C0
bcs L9B38
jsr L9E07
jmp L9B48
@ -1898,46 +1889,25 @@ start: ldy #0
copy16 icon_ptrs,x, $06
jsr calc_icon_poly
lda poly::v0::ycoord
cmp rect::y2
lda poly::v0::ycoord+1
sbc rect::y2+1
cmp16 poly::v0::ycoord, rect::y2
bpl done
lda poly::v5::ycoord
cmp rect::y1
lda poly::v5::ycoord+1
sbc rect::y1+1
cmp16 poly::v5::ycoord, rect::y1
bmi done
lda poly::v5::xcoord
cmp rect::x2
lda poly::v5::xcoord+1
sbc rect::x2+1
cmp16 poly::v5::xcoord, rect::x2
bpl done
lda poly::v4::xcoord
cmp rect::x1
lda poly::v4::xcoord+1
sbc rect::x1+1
cmp16 poly::v4::xcoord, rect::x1
bmi done
lda poly::v7::ycoord
cmp rect::y2
lda poly::v7::ycoord+1
sbc rect::y2+1
cmp16 poly::v7::ycoord, rect::y2
bmi L9F8F
lda poly::v7::xcoord
cmp rect::x2
lda poly::v7::xcoord+1
sbc rect::x2+1
cmp16 poly::v7::xcoord, rect::x2
bpl done
lda poly::v2::xcoord
cmp rect::x1
lda poly::v2::xcoord+1
sbc rect::x1+1
cmp16 poly::v2::xcoord, rect::x1
bpl L9F8F
done: lda #0
@ -2760,10 +2730,7 @@ LA674: lda poly::v4::xcoord,x
sta setportbits_params2::cliprect::x2,x
dex
bpl LA674
lda LA62B
cmp #$2F
lda LA62C
sbc #$02
cmp16 LA62B, #$22F
bmi LA69C
lda #$2E
sta LA62B
@ -2960,42 +2927,24 @@ LA846: jsr pop_zp_addrs
adc LA6C4
sta LA6C4
add16 LA6C5, grafport4::viewloc::ycoord, LA6C5
lda setportbits_params2::cliprect::x2
cmp LA6C3
lda setportbits_params2::cliprect::x2+1
sbc LA6C4
cmp16 setportbits_params2::cliprect::x2, LA6C3
bmi LA8B7
add16 LA6C3, #1, setportbits_params2::cliprect::x2
jmp LA8D4
LA8B7: lda grafport4::viewloc::xcoord
cmp setportbits_params2::cliprect::x1
lda grafport4::viewloc::xcoord+1
sbc setportbits_params2::cliprect::x1+1
LA8B7: cmp16 grafport4::viewloc::xcoord, setportbits_params2::cliprect::x1
bmi LA8D4
lda grafport4::viewloc::xcoord
sta setportbits_params2::cliprect::x2
lda grafport4::viewloc::xcoord+1
sta setportbits_params2::cliprect::x2+1
copy16 grafport4::viewloc::xcoord, setportbits_params2::cliprect::x2
jmp LA6FA
LA8D4: lda grafport4::viewloc::ycoord
cmp setportbits_params2::cliprect::y1
lda grafport4::viewloc::ycoord+1
sbc setportbits_params2::cliprect::y1+1
LA8D4: cmp16 grafport4::viewloc::ycoord, setportbits_params2::cliprect::y1
bmi LA8F6
lda grafport4::viewloc::ycoord
sta setportbits_params2::cliprect::y2
lda grafport4::viewloc::ycoord+1
sta setportbits_params2::cliprect::y2+1
copy16 grafport4::viewloc::ycoord, setportbits_params2::cliprect::y2
lda #1
sta L9F93
jmp LA6FA
LA8F6: lda LA6C5
cmp setportbits_params2::cliprect::y2
lda LA6C6
sbc setportbits_params2::cliprect::y2+1
LA8F6: cmp16 LA6C5, setportbits_params2::cliprect::y2
bpl LA923
lda LA6C5
clc
@ -5978,10 +5927,7 @@ L415B: sta active_window_id
lda ($06),y
sbc grafport2::viewloc::ycoord+1
sta L4243
lda L4242
cmp #$0F
lda L4243
sbc #$00
cmp16 L4242, #$0F
bpl L41CB
jsr L6E8A
ldx #$0B
@ -9646,15 +9592,9 @@ L602A: lda event_params_coords,x
sta L60CF,x
dex
bpl L602A
lda event_params_xcoord
cmp $E234
lda event_params_xcoord+1
sbc $E235
cmp16 event_params_xcoord, $E234
bpl L6068
lda event_params_xcoord
cmp rect_E230
lda event_params_xcoord+1
sbc $E231
cmp16 event_params_xcoord, rect_E230
bmi L6054
bit L60D3
bpl L6068
@ -9666,15 +9606,9 @@ L6054: copy16 event_params_xcoord, rect_E230
L6068: copy16 event_params_xcoord, $E234
lda #$00
sta L60D3
L6079: lda event_params_ycoord
cmp $E236
lda event_params_ycoord+1
sbc $E237
L6079: cmp16 event_params_ycoord, $E236
bpl L60AE
lda event_params_ycoord
cmp $E232
lda event_params_ycoord+1
sbc $E233
cmp16 event_params_ycoord, $E232
bmi L609A
bit L60D4
bpl L60AE
@ -9976,10 +9910,7 @@ L638C: jsr L650F
lda grafport2::cliprect::y1+1
sbc #$00
sta L63EB
lda L63EA
cmp L7B61
lda L63EB
sbc L7B62
cmp16 L63EA, L7B61
bmi L63C1
ldax L63EA
jmp L63C7
@ -10000,10 +9931,7 @@ L63EC: jsr L650F
jsr L644C
sta L6448
add16_8 grafport2::cliprect::y2, L6448, L644A
lda L644A
cmp L7B65
lda L644B
sbc L7B66
cmp16 L644A, L7B65
bpl L6421
ldax L644A
jmp L6427
@ -10033,10 +9961,7 @@ L644C: tya
L6451: jsr L650F
stax L64AC
sub16 grafport2::cliprect::x1, L64AC, L64AE
lda L64AE
cmp L7B5F
lda L64AF
sbc L7B60
cmp16 L64AE, L7B5F
bmi L6484
ldax L64AE
jmp L648A
@ -10055,10 +9980,7 @@ L64AF: .byte 0
L64B0: jsr L650F
stax L650B
add16 grafport2::cliprect::x2, L650B, L650D
lda L650D
cmp L7B63
lda L650E
sbc L7B64
cmp16 L650D, L7B63
bpl L64E3
ldax L650D
jmp L64E9
@ -10134,10 +10056,7 @@ L656D: lda active_window_id
bpl L65D0
lda #$00
beq L65EB
L65D0: lda grafport2::cliprect::x2
cmp L7B63
lda grafport2::cliprect::x2+1
sbc L7B64
L65D0: cmp16 grafport2::cliprect::x2, L7B63
bmi L65E2
tya
jmp L65EE
@ -10181,10 +10100,7 @@ L6604: lda active_window_id
bpl L6669
lda #$00
beq L668A
L6669: lda grafport2::cliprect::y2
cmp L7B65
lda grafport2::cliprect::y2+1
sbc L7B66
L6669: cmp16 grafport2::cliprect::y2, L7B65
bmi L667B
tya
jmp L668D
@ -10488,15 +10404,9 @@ L6994: lda event_params_coords,x
sta L6A39,x
dex
bpl L6994
lda event_params_xcoord
cmp $E234
lda event_params_xcoord+1
sbc $E235
cmp16 event_params_xcoord, $E234
bpl L69D2
lda event_params_xcoord
cmp rect_E230
lda event_params_xcoord+1
sbc $E231
cmp16 event_params_xcoord, rect_E230
bmi L69BE
bit L6A3D
bpl L69D2
@ -10508,15 +10418,9 @@ L69BE: copy16 event_params_xcoord, rect_E230
L69D2: copy16 event_params_xcoord, $E234
lda #$00
sta L6A3D
L69E3: lda event_params_ycoord
cmp $E236
lda event_params_ycoord+1
sbc $E237
L69E3: cmp16 event_params_ycoord, $E236
bpl L6A18
lda event_params_ycoord
cmp $E232
lda event_params_ycoord+1
sbc $E233
cmp16 event_params_ycoord, $E232
bmi L6A04
bit L6A3E
bpl L6A18
@ -10914,15 +10818,9 @@ L6DC0: jsr L6E52
L6DC9: lda active_window_id
sta getwinport_params2::window_id
jsr L44F2
lda L7B5F
cmp grafport2::cliprect::x1
lda L7B60
sbc grafport2::cliprect::x1+1
cmp16 L7B5F, grafport2::cliprect::x1
bmi L6DFE
lda grafport2::cliprect::x2
cmp L7B63
lda grafport2::cliprect::x2+1
sbc L7B64
cmp16 grafport2::cliprect::x2, L7B63
bmi L6DFE
lda #$02
sta event_params
@ -10937,15 +10835,9 @@ L6DFE: lda #$02
sta event_params+1
jsr L6E48
jsr L656D
L6E0E: lda L7B61
cmp grafport2::cliprect::y1
lda L7B62
sbc grafport2::cliprect::y1+1
L6E0E: cmp16 L7B61, grafport2::cliprect::y1
bmi L6E38
lda grafport2::cliprect::y2
cmp L7B65
lda grafport2::cliprect::y2+1
sbc L7B66
cmp16 grafport2::cliprect::y2, L7B65
bmi L6E38
lda #$01
sta event_params
@ -11270,10 +11162,7 @@ L710A: lsr L72A9
lda L72A9
sbc #$00
sta L72A9
lda L72A8
cmp L70C1
lda L72A9
sbc L70C2
cmp16 L72A8, L70C1
bcs L7169
L7147: lda $EC2E
jsr L8B19
@ -11889,15 +11778,9 @@ L76C4: jsr L7B6B
lda L7B66
sbc #$00
sta L7B66
lda L7B63
cmp #$AA
lda L7B64
sbc #$00
cmp16 L7B63, #$AA
bmi L7705
lda L7B63
cmp #$C2
lda L7B64
sbc #$01
cmp16 L7B63, #$1C2
bpl L770C
ldax L7B63
jmp L7710
@ -11913,15 +11796,9 @@ L7710: ldy #$20
txa
iny
sta ($06),y
lda L7B65
cmp #$32
lda L7B66
sbc #$00
cmp16 L7B65, #$32
bmi L7739
lda L7B65
cmp #$6C
lda L7B66
sbc #$00
cmp16 L7B65, #$6C
bpl L7740
ldax L7B65
jmp L7744
@ -12242,10 +12119,7 @@ L7AEA: sta str_6_spaces,x
ldx #$00
L7AF9: lda #$00
sta L7B5D
L7AFE: lda L7B5B
cmp L7B53,x
lda L7B5C
sbc L7B54,x
L7AFE: cmp16 L7B5B, L7B53,x
bpl L7B31
lda L7B5D
bne L7B1A
@ -12399,15 +12273,9 @@ L7C56: lda ($06),y
bmi L7C88
bit L7B68
bmi L7CCE
lda L7B67
cmp L7B5F
lda L7B68
sbc L7B60
cmp16 L7B67, L7B5F
bmi L7CCE
lda L7B67
cmp L7B63
lda L7B68
sbc L7B64
cmp16 L7B67, L7B63
bpl L7CBF
jmp L7CDA
@ -12415,46 +12283,25 @@ L7C88: bit L7B68
bmi L7CA3
bit L7B64
bmi L7CDA
lda L7B67
cmp L7B63
lda L7B68
sbc L7B64
cmp16 L7B67, L7B63
bmi L7CDA
jmp L7CBF
L7CA3: lda L7B67
cmp L7B5F
lda L7B68
sbc L7B60
L7CA3: cmp16 L7B67, L7B5F
bmi L7CCE
lda L7B67
cmp L7B63
lda L7B68
sbc L7B64
cmp16 L7B67, L7B63
bmi L7CDA
L7CBF: lda L7B67
sta L7B63
lda L7B68
sta L7B64
L7CBF: copy16 L7B67, L7B63
jmp L7CDA
L7CCE: lda L7B67
sta L7B5F
lda L7B68
sta L7B60
L7CCE: copy16 L7B67, L7B5F
L7CDA: bit L7B62
bmi L7D03
bit L7B6A
bmi L7D49
lda L7B69
cmp L7B61
lda L7B6A
sbc L7B62
cmp16 L7B69, L7B61
bmi L7D49
lda L7B69
cmp L7B65
lda L7B6A
sbc L7B66
cmp16 L7B69, L7B65
bpl L7D3A
jmp L7D55
@ -12462,33 +12309,18 @@ L7D03: bit L7B6A
bmi L7D1E
bit L7B66
bmi L7D55
lda L7B69
cmp L7B65
lda L7B6A
sbc L7B66
cmp16 L7B69, L7B65
bmi L7D55
jmp L7D3A
L7D1E: lda L7B69
cmp L7B61
lda L7B6A
sbc L7B62
L7D1E: cmp16 L7B69, L7B61
bmi L7D49
lda L7B69
cmp L7B65
lda L7B6A
sbc L7B66
cmp16 L7B69, L7B65
bmi L7D55
L7D3A: lda L7B69
sta L7B65
lda L7B6A
sta L7B66
L7D3A: copy16 L7B69, L7B65
jmp L7D55
L7D49: lda L7B69
sta L7B61
lda L7B6A
sta L7B62
L7D49: copy16 L7B69, L7B61
L7D55: inc L7D5B
jmp L7BEF
@ -12993,10 +12825,7 @@ L81AC: lda pointC::ycoord
sta pointC::ycoord
bcc L81BB
inc pointC::ycoord+1
L81BB: lda point9::ycoord
cmp grafport2::cliprect::y2
lda point9::ycoord+1
sbc grafport2::cliprect::y2+1
L81BB: cmp16 point9::ycoord, grafport2::cliprect::y2
bmi L81D9
lda point9::ycoord
clc
@ -13012,10 +12841,7 @@ L81D9: lda point9::ycoord
sta point9::ycoord
bcc L81E8
inc point9::ycoord+1
L81E8: lda point9::ycoord
cmp grafport2::cliprect::y1
lda point9::ycoord+1
sbc grafport2::cliprect::y1+1
L81E8: cmp16 point9::ycoord, grafport2::cliprect::y1
bpl L81F7
rts
@ -13077,10 +12903,7 @@ L827A: sta text_buffer2::data-1,x
ldx #$00
L828C: lda #$00
sta L8274
L8291: lda L8272
cmp L826A,x
lda L8273
sbc L826B,x
L8291: cmp16 L8272, L826A,x
bpl L82C3
lda L8274
bne L82AD
@ -16117,10 +15940,7 @@ L9BC9: yax_call JT_MLI_RELAY, GET_FILE_INFO, file_info_params3
jmp L9BC9
L9BDA: sub16 file_info_params3::aux_type, file_info_params3::blocks_used, L9BFF
lda L9BFF
cmp LA2EF
lda L9C00
sbc LA2F0
cmp16 L9BFF, LA2EF
bcs L9BFE
jmp L9185
@ -16186,10 +16006,7 @@ L9C70: yax_call JT_MLI_RELAY, GET_FILE_INFO, file_info_params3
L9C95: sub16 file_info_params3::aux_type, file_info_params3::blocks_used, L9CD4
add16 L9CD4, L9CD8, L9CD4
lda L9CD4
cmp file_info_params2::blocks_used
lda L9CD5
sbc file_info_params2::blocks_used+1
cmp16 L9CD4, file_info_params2::blocks_used
bcs L9CCC
sec
bcs L9CCD
@ -19062,10 +18879,7 @@ LB9B8: MGTK_RELAY_CALL MGTK::ScreenToWindow, event_params
LB9D8: jsr LBD3B
stax $06
lda $D20D
cmp $06
lda $D20E
sbc $06+1
cmp16 $D20D, $06
bcs LB9EE
jmp LBA83
@ -19083,10 +18897,7 @@ LB9D8: jsr LBD3B
sta ptr+2
LBA10: MGTK_RELAY_CALL MGTK::TextWidth, ptr
add16 $09, LBB09, $09
lda $09
cmp $D20D
lda $0A
sbc $D20E
cmp16 $09, $D20D
bcc LBA42
dec $08
lda $08
@ -19141,10 +18952,7 @@ LBA7C: dey
sta textlen
: MGTK_RELAY_CALL MGTK::TextWidth, params
add16 result, point6::xcoord, result
lda result
cmp $D20D
lda result+1
sbc $D20E
cmp16 result, $D20D
bcc LBABF
dec textlen
lda textlen
@ -19527,10 +19335,7 @@ LBDDF: lda LD909
ldx #$00
LBDFE: lda #$00
sta LBE61
LBE03: lda LBE5F
cmp LBE57,x
lda LBE5F+1
sbc LBE57+1,x
LBE03: cmp16 LBE5F, LBE57,x
bpl LBE35
lda LBE61
bne LBE1F

View File

@ -171,3 +171,36 @@
sta arg2+1
.endif
.endmacro
.macro cmp16 arg1, arg2, arg3
.if (.match ({arg2}, x) .or .match ({arg2}, y))
;; indexed variant (arg2 is x or y)
lda arg1,arg2
cmp arg3
lda arg1+1,arg2
sbc arg3+1
.elseif (.match ({arg3}, x) .or .match ({arg3}, y))
;; indexed variant (arg3 is x or y)
lda arg1
cmp arg2,arg3
lda arg1+1
sbc arg2+1,arg3
.elseif (.match (.mid (0, 1, {arg1}), #))
;; immediate variant (arg1 is #nnnn)
lda #<(.right (.tcount ({arg1})-1, {arg1}))
cmp arg2
lda #>(.right (.tcount ({arg1})-1, {arg1}))
sbc arg2+1
.elseif (.match (.mid (0, 1, {arg2}), #))
;; immediate variant (arg2 is #nnnn)
lda arg1
cmp #<(.right (.tcount ({arg2})-1, {arg2}))
lda arg1+1
sbc #>(.right (.tcount ({arg2})-1, {arg2}))
.else
lda arg1
cmp arg2
lda arg1+1
sbc arg2+1
.endif
.endmacro